//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import { mapMutations } from 'vuex';
import extend from './q_operations_recycleExtend.js';
import options from './q_operations_recycleOptions.js';
import detailOptions from '../q_operations_recycleList/q_operations_recycleListOptions.js';
export default function () {
	return {
		data() {
			let _options = options();
			_options.extend = extend;
			_options.detailOptions = detailOptions();
			return {
				options: _options
			};
		},
		methods: {
			...mapMutations(['setSalesContractDataStore', 'setPageIDStore']),
			onInited() {
				//页面参数初始化
			},
			formatter(row, column, index) {
				//自定义格式化
				return '';
			},
			rowClick(index, row, column) {
				//行点击事件(默认触发编辑)
				//行点击事件(默认触发编辑)
				this.setPageIDStore(row.Operations_recycle);
				let url = '/operationsinfo/q_operations_recycle/Detail/Detail?operationsinfo=' + row.Operations_recycle;
				uni.navigateTo({
					url: url
				});
				return false;
				// return true;
			},
			cellClick(index, row, column) {
				//单元格击事件(默认触发编辑)
				//仅onInited中设置：this.direction = "horizontal", this.columns的字段设置为click=true后生效
				return true;
			},
			rowButtons(index, row) {
				//列表显示的按钮
				//自定义按钮,仅onInited中设置：this.direction = "list"后生效
			
				if (row.AuditStatus === 0) {
					return [
						{
							text: '审核',
							type: 'error',
							shape: 'circle'
						},
						{
							text: '编辑',
							type: 'warning',
							shape: 'circle'
						}
					];
				}
				//返回查看审批按钮
				return [
					{
						text: '查看审核',
						type: 'primary',
						shape: 'circle'
					}
				];
			},
			rowButtonClick(btn, index, row) {
				//列表显示的按钮点击事件
				if (btn.text == '编辑') {
					this.$toast('编辑，跳到新增页面');
					uni.setStorageSync('q_operations_recycle', row);
					const optionsObj = {
						editFormOptions: this.options.editFormOptions,
						detailColumns: this.options.detailOptions.columns,
						detailtable: this.options.table
					};
					uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
					uni.navigateTo({
						url: '/pages/addPage/addPage?biaoming=q_operations_recycle&&currentAction=Update&&ID=Operations_recycle&&zibiaoming=q_operations_recycle_not'
					});
					return;
				}
				this.setSalesContractDataStore({ workTable: 'q_operations_recycle', tableKey: row.Operations_recycle });
				try {
					uni.navigateTo({
						url: `/operationsinfo/q_operations_recycle/q_operations_recycleAduit?workTable=q_operations_recycle&&tableKey=` + row.Operations_recycle
					});
				} catch (e) {
					//TODO handle the exception
					console.log(e);
				}
			},
			searchBefore(params) {
				//查询前
				return true;
			},
			updateBefore(formData) {
				//更新保存前操作
				return true;
			},
			addBefore(formData) {
				//新建保存前操作
				return true;
			},
			searchFormOnChange(field, value) {
				//查询弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			},
			editFormOnChange(field, value) {
				//新建编辑弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			}
		}
	};
}
